﻿using MediatR;
using RBAC.LuFang.API.Application.Command.RoleMenuCommand;
using RBAC.LuFang.Domain;
using RBAC.LuFang.Domin.Services;

namespace RBAC.LuFang.API.Application.CommandHandlers.RoleMenuHandler
{
    //角色菜单添加
    public class RoleMenuCreateCommandHandler:IRequestHandler<RoleMenuCreateCommand,int>
    {
        private readonly IRoleMenuService _rolemenuService;

        public RoleMenuCreateCommandHandler(IRoleMenuService rolemenuService)
        {
            _rolemenuService = rolemenuService;
        }

        public async Task<int> Handle(RoleMenuCreateCommand request, CancellationToken cancellationToken)
        {
            var rolemenuModel = new RoleMenu();
           var rid= rolemenuModel.RoleId = request.rid;
            return await _rolemenuService.AddRoleMenu(rid, request.mid);
        }
    }
}
